﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ModelBinder.Models;

namespace ModelBinder.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult Create()
        {
            return View();
        }


        public ActionResult Save(User user, string pippo)
        {
            return View("Save", user);
        }

        public ActionResult Save1([Bind(Prefix = "")]User user)
        {
            return View("Save", user);
        }

        public ActionResult Save2([Bind(Include = "Username, Email")]User user)
        {
            return View("Save", user);
        }

        public ActionResult Save3([Bind(Exclude = "Password")]User user)
        {
            return View("Save", user);
        }

        public ActionResult Save4()
        {
            User user = new User();
            TryUpdateModel<IUserBindable>(user);
            return View("Save", user);
        }
    }
}
